using System.ComponentModel.DataAnnotations;
using Microsoft.EntityFrameworkCore;
using PowerManage.Entity.Enums;

namespace PowerManage.Entity;

/**
 * 权限实体
 * index为对应的字段创建索引，nameof指定字段，IsUnique指定是否是唯一索引
 */
[Index(nameof(Sort))]
[Index(nameof(ParentId))]
[Index(nameof(Code), IsUnique = true)]
public class ElePermission : EleEntity
{
    [Comment("权限名称")] [MaxLength(20)] public string Name { get; set; } = string.Empty;
    [Comment("权限编码")] [MaxLength(100)] public string Code { get; set; } = string.Empty;
    [Comment("url地址")] [MaxLength(200)] public string? Url { get; set; }
    [Comment("vue页面组件")] [MaxLength(200)] public string? Component { get; set; }
    [Comment("图标")] [MaxLength(100)] public string? Icon { get; set; }

    [Comment("菜单类型：0：菜单权限、1：按钮权限、2：Api权限")]
    public PermissionType PermissionType { get; set; }

    [Comment("API方法：GET、PUT、POST、DELETE")]
    [MaxLength(10)]
    public string? ApiMethod { get; set; }

    [Comment("排序")] public int Sort { get; set; }
    [Comment("父菜单Id")] public long ParentId { get; set; }
    [Comment("状态：1：正常、0：禁用")] public PermissionStatus Status { get; set; }
    [Comment("备注")] [MaxLength(500)] public string? Remark { get; set; }
}